//
//  MenuController.m
//  GKBHouse
//
//  Created by  on 12-7-13.
//  Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
//

#import "MenuController.h"
#import "GKBNavigationBar.h"
#import "SettingController.h"
#import "GKBMainController.h"
#import "ResetPassword.h"
@implementation MenuController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
        
    }
    return self;
}

- (void)didReceiveMemoryWarning
{
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    [cancel setTitle:NSLocalizedString(@"cancel", nil)  forState:UIControlStateNormal];
    [cancel addTarget:self action:@selector(closeView) forControlEvents:UIControlEventTouchUpInside];
    [local setText:NSLocalizedString(@"Change user", nil)];
    [set setText:NSLocalizedString(@"set", nil)];
    [resetPasswordLabel setText:NSLocalizedString(@"resetPassWord", nil)];
    
    [localBut addTarget:self action:@selector(localButAction) forControlEvents:UIControlEventTouchUpInside];
    [setBut addTarget:self action:@selector(setButAction) forControlEvents:UIControlEventTouchUpInside];
    [resetPassword addTarget:self action:@selector(resetAction) forControlEvents:UIControlEventTouchUpInside];
    
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

//- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
//{
//    // Return YES for supported orientations
//    return (interfaceOrientation == UIInterfaceOrientationPortrait);
//}
- (void)initTopBar
{    
    GKBNavigationBar *topBar = [[GKBNavigationBar alloc]init];
    [topBar setTarget:self returnAction:@selector(closeView) withTitle:@"电视"];
    [self.view addSubview:topBar];    
    [topBar release];
    
}

- (void)localButAction
{
    [LoginController1 setAutoLogin:NO];
        GKBMainController *mainCtr = [GKBMainController mainCtr];
        [mainCtr dismissView];
}
- (void)closeView
{
    [self.view removeFromSuperview];
}

- (void)setButAction
{
    [self closeView];
    SettingController *setting = [[SettingController alloc]init];
    //[[UIApplication sharedApplication].keyWindow.rootViewController presentModalViewController:setting animated:NO];
    [[GKBMainController mainCtr] presentModalViewController:setting animated:NO];
    [setting release];
    
    [GKBMainController postStopRefresh];
}
- (void)resetAction
{
    [self closeView];
    ResetPassword *reset = [[ResetPassword alloc]init];
    [[GKBMainController mainCtr] presentModalViewController:reset animated:NO];
    [reset release];
    
    [GKBMainController postStopRefresh];
}
@end
